<template>
    <van-swipe :autoplay="3000" lazy-render>
        <van-swipe-item v-for="image in images" :key="image">
            <img :src="image.pic" />
        </van-swipe-item>
    </van-swipe>
</template>

<script>
import { lunbo } from '../../api/user'

export default {
    data() {
        return {
            images: [],//轮播图数据
        }
    },
    methods: {
        //获取轮播图数据
        lunbodata() {
            lunbo().then((res) => {
                this.images = res.data.banners
                //console.log(res)
            }).catch((err) => {
                //console.log(err)
            })

        }
    },
    mounted() {
        this.lunbodata();
    },

    // setup() {
    //     const images = [
    //         'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    //         'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
    //     ];
    //     return { images };
    // },
};

</script>


<style lang="less" scoped>
.van-swipe {
    width: 100%;
    height: 3rem;

    .van-swipe__track {
        .van-swipe-item {
            text-align: center;

            img {
                width: 90%;
                height: 3rem;
                border-radius: 0.5rem;

            }
        }
    }
}
</style>